#include "aspect.h"
#include <string>
#include <stdio.h>
class AspectLogic{
public:
	void sayHello(aspect::Aspect &aspect,int &a,int &b); 
	void assert(aspect::Aspect &aspect,int &a,int &b); 
	void assert1(aspect::Aspect &aspect,int &a);
   void helloLogic(aspect::Aspect &aspect,std::string &content);
   void testNull(aspect::Aspect &aspect);
	DEC_ASPECT_LOGIC;
};

void AspectLogic::sayHello(aspect::Aspect &aspect,int &a,int &b)
{	 
	printf("AspectLogic::sayHello test int int %d,%d FROM %s\n",a,b,aspect.functionName().c_str());  
}

void AspectLogic::helloLogic(aspect::Aspect & aspect,std::string &content)
{
	printf("AspectLogic::helloLogic test string changed %s FROM %s ",content.c_str(),aspect.functionName().c_str());  
	content = "hello changed";
	if (aspect.isRoot())
	{
		content="now is root";
	}
	else
	{
		content = "now is child";
	}
	printf("aspect depth %d in parent %d \n",aspect.depth(),aspect.indexInParent());
	
}

void AspectLogic::assert(aspect::Aspect &aspect,int &a,int &b)
{
	printf("AspectLogic::assert aspect depth %d in parent %d  a:%d b:%d\n",aspect.depth(),aspect.indexInParent(),a,b);
}

void AspectLogic::assert1(aspect::Aspect &aspect,int &a)
{
	printf("AspectLogic::assert aspect depth %d in parent %d  a:%d \n",aspect.depth(),aspect.indexInParent(),a);
}

void AspectLogic::testNull(aspect::Aspect &aspect)
{
	printf(" AspectLogic::testNull test null arg\n");
}
 

ASPECT_LOGIC(AspectLogic)	
{
	BIND_ASPECT("ATest.cpp:a_b",&AspectLogic::sayHello,ARG2(int,int));

	BIND_ASPECT("ATest.cpp:logic",&AspectLogic::helloLogic,ARG1(std::string));
	
	BIND_ASPECT("ATest.cpp:assert_a_b",&AspectLogic::assert,ARG2(int,int));
	
	BIND_ASPECT("ATest.cpp:a_b_child",&AspectLogic::testNull,ARG());
	
	BIND_ASPECT("ATest.cpp:logic_a",&AspectLogic::assert,ARG2(int,int));
	BIND_ASPECT("ATest.cpp:logic_a",&AspectLogic::assert1,ARG1(int));
}



